<script type="text/javascript" src="<?= base_url() . 'resource/js/layer/layer.js' ?>" charset="utf-8"></script>
<script type="text/javascript" src="<?= base_url() . 'resource/js/vue.js' ?>" charset="utf-8"></script>
<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
    <div class="page-header">
        <div class="container-fluid">
          <h1><?=lang('menu_yhgl')?></h1>
          <?=$this->breadcrumb->generateHTML();?>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-list"></i>用户操作日志</h3>
          </div>
          <div class="panel-body" id="contents">
            <div class="well" style="padding:0 19px;">
              <div class="row">
                <form action="<?= blang_url('users/SqlLog/index') ?>" method="get" name="searchform">
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="control-label">用户</label>
                            <select class="form-control" name="user_id" data-edit-select="1">
                                <option value="">--用户--</option>
                                <option v-for="item in users" v-bind:value="item.id" :selected="item.id==search.user_id">{{item.name}}</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="control-label">普通单维修单号搜索</label>
                            <input class="form-control" type="text" name="order_num" placeholder="普通单维修单号搜索" :value="search.order_num">
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="control-label">批量单维修单号搜索</label>
                            <input class="form-control" type="text" name="order_num_multi" placeholder="批量单维修单号搜索" :value="search.order_num_multi">
                        </div>
                        <input class="btn btn-primary pull-right" style="margin-bottom: 19px;" type="submit" name="searchSubmit" value="查询"/>
                    </div>
                </form>
              </div>
            </div>
            <div class="table-responsive">
                <table class="table table-bordered table-hover oms-table">
                  <thead>
                    <tr>
                        <th class="text-left">用户ID</th>
                        <th class="text-left">用户</th>
                        <th class="text-left">操作描述</th>
                        <th class="text-right">中国时间</th>
                        <th class="text-right">ip</th>
                        <th class="text-right">详情</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr v-for="item in list" :id="'sql-log-tr-' + item.id">
                        <td class="text-left">{{item.user_id}}</td>
                        <td class="text-left">{{item.user_name}}</td>
                        <td class="text-left">{{item.desc}}</td>
                        <td class="text-right">{{item.create_at}}</td>
                        <td class="text-right">{{item.ip}}</td>
                        <td class="text-right">
                            <a class="btn btn-primary btn-sm" href="javascript:void(0)" @click="detail(item.id, $event)">查看详情</a>
                        </td>
                    </tr>
                    <tr v-if="isEmpty">
                        <td colspan="6" class="emptyNumber"><?=lang('public_mygdsj')?>....</td>
                    </tr>
                    
                </tbody>
                </table>
                <?php if($show_pages):?>
                <div class="page">
                    <?=$show_pages?>
                </div>
                <?php endif;?>
            </div>
          </div>
        </div>
    </div>
  <script type="text/javascript">
~function(){
    var users = <?= json_encode($users) ?>;
    var list = <?= json_encode($list) ?>;
    var search = <?= json_encode($search) ?>;
    var vm = new Vue({
        el:'#contents',
        data:{
            isEmpty:$.isEmptyObject(list),
            users:users,
            list:list,
            search:search
        },
        methods:{
            detail:detail
        }
    });
    function detail(id, e){console.log(id);
        var url = '<?= blang_url('users/SqlLog/detail/') ?>';
        $.get(url, {id:id}, function(response){
            var index = layer.open({
                id:'sql-log-detail',
                scrollbar:false,
                title:'操作日志详情:',
                type: 1,
                btn:['关闭'],
                area: ['650px', '500px'],
                content: response,
                yes:function(){
                    layer.close(index);
                }
            });
        });
    }

}();
$(function(){
    $("select[data-edit-select]").filterSelect();
});
</script>
</div>